home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 42
/
Amiga Format AFCD42 (Issue 126, Aug 1999).iso
/
-serious-
/
programming
/
other
/
ioblixdevkit
/
autodocs
/
ioblix.doc
next >
Wrap
Text File
|
1999-05-14
|
18KB
|
475 lines
TABLE OF CONTENTS
ioblix.resource/--background--
ioblix.resource/AddIRQHook
ioblix.resource/AllocChipList
ioblix.resource/FindChip
ioblix.resource/FreeChipList
ioblix.resource/ObtainChip
ioblix.resource/ObtainChipShared
ioblix.resource/ReleaseChip
ioblix.resource/ReleaseChipShared
ioblix.resource/RemIRQHook
ioblix.resource/--background-- ioblix.resource/--background--
PURPOSE
The ioblix.resource is created by SetupIOBlix during startup and provides
several functions to gain exclusive as well as shared access to any chip
the IOBlix multi I/O boards provide. If you ever want to use one of the
IOBlix chips you should ALWAYS use either ObtainChip() or
ObtainChipShared() to prevent other ioblix.resource-conform programs from
interferring with your program. All device drivers being delivered with
your IOBlix board follow this rule. And hopefully all third-party drivers
will also do.
To access these functions just call OpenResource(IOBLIXRESNAME) and use
the returned pointer in the same manner as library bases are used.
ioblix.resource/AddIRQHook ioblix.resource/AddIRQHook
NAME
AddIRQHook - add a private interrupt function to the IOBlix interrupt
chain
SYNOPSIS
void = AddIRQHook( node )
A0
void AddIRQHook( struct IRQHookNode * );
FUNCTION
Adds the given node to the IOBlix interrupt chain. This is necessary
because normal interrupt handling by AmigaOS will loose some interrupts on
heavy system load.
Just imagine two applications using the IOBlix board (eg one serial and
one parallel port). When adding your own interrupt function with Exec's
AddIntServer() the system will just recognize the first of two
simultaneously happening interrupts, because the first function will return
a successfull interrupt handling and Exec will cease any further handling
within its chain. But at this time the second interrupt has still not been
processed. IOBlix' own interrupt chain avoids this problem by checking all
active chips before returning control to Exec.
The function given in ihn_HookFunc will be passed the data given in
ihn_HookUserData on the stack. Just as Exec's interrupt handling functions
a return value of 0 indicates that no interrupt has happened. Any other
return value indicates a successfull interrupt handling.
INPUTS
node -- a correctly initialized IRQHookNode
EXAMPLE
/* add a private interrupt function */
ULONG __saveds myIRQFunc( APTR userData);
APTR myUserData;
struct IRQHookNode *node;
if (IOBlixBase = OpenResource(IOBLIXRESNAME)) {
node->ihn_Node.ln_Name = "TestHook";
node->ihn_Node.ln_Pri = 5; /* priority within the chain */
node->ihn_HookFunc = myIRQFunc;
node->ihn_HookUserData = myUserData;
AddIRQHook(node);
/* do whatever you want */
RemIRQHook(node);
}
ULONG myIRQFunc( APTR userData )
{
/* check wether an interrupt has happened or not */
/* if yes, then do all necessary things and return a value of != 0 */
/* else just return 0 */
}
SEE ALSO
RemIRQHook
ioblix.resource/AllocChipList ioblix.resource/AllocChipList
NAME
AllocChipList -- get a list of all available chips
SYNOPSIS
list = AllocChipList( void )
D0
struct List *AllocChipList( void );
FUNCTION
This function returns a copy of the internal list of all available chips.
You are allowed to iterate through the list, but you must not change
anything. All nodes in the list are of type (struct IOBlixChipNode *). No
chip in the list is obtained in a ObtainChip()-like manner.
RESULTS
chipNode -- a list of all available chips, or NULL if the call failed
EXAMPLE
/* print information about all IOBlix chips in the system */
struct IOBlixResource *IOBlixBase;
struct List *list;
struct IOBlixChipNode *node;
if (IOBlixBase = OpenResource(IOBLIXRESNAME)) {
if (list = AllocChipList()) {
node = (struct IOBlixChipNode *)chipList->lh_Head;
while (node->icn_Node.ln_Succ) {
switch (node->icn_Type) {
case ICT_Z2_SERIAL_CHIP:
printf("IOBlix Z2 UART, %s, %ld bytes FIFO\n",
node->icn_Description, node->icns_FIFOSize);
break;
case ICT_Z2_PARALLEL_CHIP:
printf("IOBlix Z2 parallel port, %s, %ld bytes FIFO\n",
node->icn_Description, node->icnp_FIFOSize);
break;
default:
break;
printf("chip is in use by %s\n",
(node->icn_Owner) ? node->icn_Owner : "nobody");
}
node = (struct IOBlixChipNode *)node->icn_Node.ln_Succ);
}
FreeChipList(list);
} else {
printf("failed to allocate chip list\n");
}
}
SEE ALSO
FreeChipList
ioblix.resource/FindChip ioblix.resource/FindChip
NAME
FindChip -- find a chip in the resource's database
SYNOPSIS
chipNode = FindChip(chipType, chipNum)
D0 D0 D1
struct IOBlixChipNode *FindChip( ULONG, ULONG );
FUNCTION
This function searches the internal list for the chip matching the given
values for chip type and number. If the search is successfull the chip's
information block is returned, but the chip is NOT obtained!
You may use this function just to check if a certian chip is available
and to get some information about it. All fields in IOBlixChipNode are
considered READ-ONLY, you must not change anything.
INPUTS
chipType -- the type of chip you want to find
chipNum -- internal number of the chip you want to find
valid range is 0..IOBLIX_Z2_NUM_SERUNITS for UARTs
0..IOBLIX_Z2_NUM_PARUNITS for parallel ports
0..IOBLIX_Z2_NUM_FIFOUNITS for external FIFOs
to obtain a chip on multiple IOBlix boards use
boardNum*10+chipNum as value, ie 13 is the third UART on the
second board
RESULTS
chipNode -- a pointer to the chip's information block, or NULL if the
chip is not available.
EXAMPLE
/* try to find serial unit 0 on first IOBlix board */
struct IOBlixResource *IOBlixBase;
struct IOBlixChipNode *chipInfo;
if (IOBlixBase = OpenResource(IOBLIXRESNAME)) {
if (chipInfo = FindChip(ICT_Z2_SERIAL_CHIP, 0)) {
/* chip is available, let's see what it is able to do */
printf("UART is a %s with %ld bytes FIFO"\n,
chipInfo->icn_Description, chipInfo->icns_FIFOSize);
printf("UART is in use by %s\n",
(chipInfo->icn_Owner) ? chipInfo->icn_Owner : "nobody");
} else {
printf("serial port #0 is not available\n");
}
}
SEE ALSO
ReleaseChip, FindChip
ioblix.resource/FreeChipList ioblix.resource/FreeChipList
NAME
FreeChipList -- free a previously allocated chip list
SYNOPSIS
void = FreeChipList( list )
A0
void FreeChipList( struct List * );
FUNCTION
This function frees the given list again.
INPUTS
list -- a list previously allocated by AllocChipList(). Passing NULL
is a no-op.
SEE ALSO
AllocChipList
ioblix.resource/ObtainChip ioblix.resource/ObtainChip
NAME
ObtainChip -- obtain a chip for exclusive use
SYNOPSIS
chipNode = ObtainChip(chipType, chipNum, newOwner, oldOwner)
D0 D0 D1 A0 A1
struct IOBlixChipN